package com.aplink.generic.util.validation;

import java.util.Calendar;

import android.widget.DatePicker;

public class CustomeDate extends ValidationBase {

	public CustomeDate() {
		this.ErrorMessage = "";
	}

	public CustomeDate(final String errormessage) {
		this.ErrorMessage = errormessage;

	}

	@Override
	public boolean checkValidation(final Object ctrlCompare) {
		if (ctrlCompare instanceof DatePicker) {
			final int day = ((DatePicker) ctrlCompare).getDayOfMonth();
			final int month = ((DatePicker) ctrlCompare).getMonth();
			final int year = ((DatePicker) ctrlCompare).getYear();

			final Calendar calendar = Calendar.getInstance();
			calendar.set(year, month, day);

			// get current date time with Calendar()
			final Calendar currentCal = Calendar.getInstance();
			return currentCal.compareTo(calendar) < 0;
		} else {
			return false;

		}
	}

}
